/*=============================================================================
*
*   Copyright (C) 2020 All rights reserved.
*
*   Filename:		register_macro.hpp
*
*   Author: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Date: 2020-01-17 16:53
*
*   Last Editors: Wang Zhecheng - wangzhecheng@yeah.net
*
*   Last modified:	2020-03-23 22:45
*
*   Description:
*
=============================================================================*/
#ifndef REGISTER_MACROS_H
#define REGISTER_MACROS_H

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
#include <boost/geometry/geometries/register/point.hpp>
////////////////////////////////////////////////////////////////
// misc

#define GEOXFEM_TYPE_TEMPLATIZED(Geometry)                  \
  template <typename... Types>                              \
  struct boost::geometry::traits::tag<Geometry<Types...>> { \
    typedef Geometry<Types...>::type type;                  \
  }
#define GEOXFEM_TYPE(Geometry)                    \
  template <>                                     \
  struct boost::geometry::traits::tag<Geometry> { \
    typedef Geometry::type type;                  \
  }
////////////////////////////////////////////////////////////////
// boost::point

#define GEOXFEM_REGISTER_2D_POINT(point_class, value_type, getX, getY, setX, \
                                  setY)                                      \
  BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(point_class, value_type,          \
                                           boost::geometry::cs::cartesian,   \
                                           getX, getY, setX, setY);

#define GEOXFEM_REGISTER_3D_POINT(point_class, value_type, getX, getY, getZ,   \
                                  setX, setY, setZ)                            \
  BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET(                                    \
    point_class, value_type, boost::geometry::cs::cartesian, getX, getY, getZ, \
    setX, setY, setZ);
////////////////////////////////////////////////////////////////

#define GEOXFEM_REGISTER(Geometry) GEOXFEM_TYPE(typename Geometry);

#define GEOXFEM_REGISTER_TEMPLATIZED(Geometry) \
  GEOXFEM_TYPE_TEMPLATIZED(typename Geometry);
////////////////////////////////////////////////////////////////

#define GEOXFEM_REGISTER_DERIVED(base, derive)                   \
  typename base::factory::template registrator<derive> TEMP_VAR( \
    base::getFactory())

#endif  // REGISTER_MACROS_H
